/****************************************************************************
*					GreedyRateRatioSequencingHeuristic
*
*	Description:	This heuristic uses a DP-type approach, greedily 
*					adding links to the sequence using a score function:			
*					- the score function is the sum of the rate of a link 
*						and a scaled product of the increase in the rates
*						of the remaining desired links as well as the 
*						decrease in the rates of the undesired ones 
*					
****************************************************************************/

#ifndef _GreedyRateRatioSequencingHeuristic_H
#define _GreedyRateRatioSequencingHeuristic_H

#include <vector>
#include "ExtendedPGMStruct.h"
#include "DataSet.h"
#include "SequencingHeuristic.h"
#include "Environment.h"

class GreedyRateRatioSequencingHeuristic : public SequencingHeuristic {
  private:

  protected:

	  // parameter of algorithm for constructing a sequence 
	  //  the greater it is the greater the effect of future assignments
	float gamma;

	  // Function to printout progress of the optimization process
	static int printoutProgress (void *instance, const lbfgsfloatval_t *x, const lbfgsfloatval_t *g, const lbfgsfloatval_t fx, const lbfgsfloatval_t xnorm, const lbfgsfloatval_t gnorm, const lbfgsfloatval_t step, int n, int k, int ls );

  public:

	  // Standard constructor
	GreedyRateRatioSequencingHeuristic(void);
      
	  // Standard destructor
    ~GreedyRateRatioSequencingHeuristic();

	  // Initialization of internal variables from environment
	int initStructure (Environment& environment);

      // Finds a good (highly probable) sequence of variables changes between two data timestamps 
	int findSequence (std::vector<unsigned int>& sequence, float& seqLogLikelihood, std::vector<float>& gradients, DataSet& dataSet, ExtendedPGMStruct& extendedPGMStruct);

}; // end of class

#endif // _SimpleParameterLearning_H
